#ifndef E1_H
#define E1_H

#include "i2c.h"

#define LED_R 0
#define LED_G 1
#define LED_B 2

#define HT16K33_ADDRESS_E1	  0xE0          //0xE0 or 0xE2 or 0xE4 or 0xE6
#define PCA9685_ADDRESS_E1    0xC0			//0xC0 or 0xC2 or 0xC4 or 0xC6

#define LED0_ON_L 0x6       // LED0 control address
#define LED0_ON_H 0x7
#define LED0_OFF_L 0x8
#define LED0_OFF_H 0x9

#define PCA9685_MODE1 0x0   // PCA9685 mode setting

#define ALLLED_ON_L 0xFA    // all LED control address
#define ALLLED_ON_H 0xFB
#define ALLLED_OFF_L 0xFC
#define ALLLED_OFF_H 0xFD

#define	SYSTEM_ON_E1			0x21
#define TUBE_ON					0x81
#define TUBE_OFF				0x80
#define ROW_OUTPUT				0xA0

// E1 address struct
typedef struct{
    i2c_addr_def rgb_addr[4];
    i2c_addr_def tube_addr[4];
} e1_addr_def;

void setPWM(uint32_t periph,uint8_t address,uint8_t num, uint16_t on, uint16_t off);//Set signal PWM
void setPWM_off(uint32_t periph,uint8_t address);
i2c_addr_def e1_init(uint8_t address);
void e1_all_init(e1_addr_def *e1_address, uint8_t e1_rgb_addr, uint8_t e1_tube_addr);
void pca9685_init(uint32_t periph, uint8_t address);
void ht16k33_init(uint32_t periph, uint8_t address);
void ht16k33_RAM_init(uint32_t periph, uint8_t address);
void display_tube(uint16_t val, i2c_addr_def e1_tube_addr);
#endif